import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;

public class Demo {
    public static void main(String[] args) {
    	try {
    		long b = System.currentTimeMillis();
			String outPutZip = "C:\\a.zip";
			ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outPutZip));
			out.setEncoding("GB2312");
			String []localFile = {"C:\\Program Files\\Windows Mail\\zh-CN\\敬亭山.docx","C:\\快盘\\敬亭山.docx"};
			
			for(int i=0; i<localFile.length; i++)
			{
				File currnetFile = new File(localFile[i]);
				File parentsFile = new File(currnetFile.getParent());
				String currentFilename= currnetFile.getName();
				String parentsFilename= parentsFile.getName();
				String finaleFilename = parentsFilename+"/"+currentFilename;
				System.out.println("localFile[i]:"+finaleFilename);
				FileInputStream fis = new FileInputStream(localFile[i]);
				out.putNextEntry(new ZipEntry(finaleFilename));
				int len;
			    byte[] buffer = new byte[1024];
			    while((len = fis.read(buffer))>0)
			    {
			  		out.write(buffer,0,len);
			    }
			}
			out.closeEntry();
			out.close();
			long e = System.currentTimeMillis();
			System.out.println(e-b);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
    
    }
}
